;
(function() {
	var role = require("./role");
	var ResponObj = require("../_include/responObj");
	var BusCon = require("../../core/bus/_con");
	var DomainCon = require("../../core/domain/_con");
	module.exports = {
		prefix: "/admin/domain",
		get: {
			"/list": function() {
				var admin = role.getAdmin(this);
				var query = this.request.query;
				var result = admin.getDomainList(query.num, query.page);
				this.body = ResponObj("json", result);
			}
		},
		post: {
			"/add": function() {
				var admin = role.getAdmin(this);
				var body = this.request.body;
				this.body = ResponObj("json", admin.addDomain(
					body.bus_id,
					body.domain,
					body.is_secondary_domain,
					body.port
				));
			}
		},
		"delete": {
			"/remove/:domain_id": function() {
				var admin = role.getAdmin(this);
				var domain_id = this.params.domain_id;
				admin.removeDomain(domain_id);
				this.body = ResponObj("string", "删除完成");
			}
		}
	}
}());